//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_mousedownclickedloop.sqf"
#include "xr_macros.sqf"

__TRACE("on");
GVARXR(mousecheckon) = true;
while {GVARXR(MouseButtons) select 1 || {GVARXR(MouseButtons) select 0}} do {
	switch (true) do {
		case (!(GVARXR(MouseButtons) select 0) && {(GVARXR(MouseButtons) select 1)}): {
			GVARXR(fangle) = GVARXR(fangle) - ((GVARXR(mouseDeltaPos) select 0) * 360);
			GVARXR(fangleY) = GVARXR(fangleY) + ((GVARXR(mouseDeltaPos) select 1) * 180);
			switch (true) do {
				case (GVARXR(fangleY) > 89): {GVARXR(fangleY) = 89};
				case (GVARXR(fangleY) < -89): {GVARXR(fangleY) = -89};
			};
			//__TRACE_2("","xr_fangle","xr_fangleY");
		};
		case ((GVARXR(MouseButtons) select 0) && {!(GVARXR(MouseButtons) select 1)}): {
			GVARXR(sdistance) = GVARXR(sdistance) - ((GVARXR(mouseDeltaPos) select 1) * 10);
			switch (true) do {
				case (GVARXR(sdistance) > GVARXR(maxDistance)): {GVARXR(sdistance) = GVARXR(maxDistance)};
				case (GVARXR(sdistance) < -GVARXR(maxDistance)): {GVARXR(sdistance) = -GVARXR(maxDistance)};
			};
			if (GVARXR(sdistance) < -0.6) then {GVARXR(sdistance) = -0.6};
			//__TRACE_1("","xr_sdistance");
		};
		case ((GVARXR(MouseButtons) select 0) && {(GVARXR(MouseButtons) select 1)}): {
			GVARXR(szoom) = GVARXR(szoom) - ((GVARXR(mouseDeltaPos) select 1) * 3);
			switch (true) do {
				case (GVARXR(szoom) > 2): {GVARXR(szoom) = 2};
				case (GVARXR(szoom) < 0.05): {GVARXR(szoom) = 0.05};
			};
			//__TRACE_1("","xr_szoom");
		};
	};
	sleep 0.0034;
};
GVARXR(mousecheckon) = false;
__TRACE("off");